package studio.raptor.databus.command;

import javax.validation.constraints.NotNull;
import org.hibernate.validator.constraints.NotEmpty;

import javax.validation.constraints.Pattern;
import java.io.Serializable;

/**
 * Created  on 2017/4/25.
 */
public class EventBasicData implements Serializable {

    private static final long serialVersionUID = -4138219791868233997L;
    /**
     * 此值需要与deliverTime的Pattern注解中正则表达式分隔符保持一致
     */
    static String DATE_SEPARATOR = "-";
    /**
     * 此值需要与deliverTime的Pattern注解中正则表达式分隔符保持一致
     */
    static String TIME_SEPARATOR = ":";
    /**
     * 事件来源
     */
    @NotEmpty(message = "source should not be empty")
    private String source;
    /**
     * 事件种类Id
     */
    @NotNull(message = "seq should not be null")
    private Integer kindId;
    /**
     * 事件名称
     */
    @NotEmpty(message = "name should not be empty")
    private String name;
    /**
     * 事件投递时间，格式: 2017-04-22 16:21:21,平、瑞年的2月份天数不支持校验
     */
    @NotEmpty(message = "deliverTime should not be empty")
    @Pattern(message = "deliverTime format error",regexp ="(19[0-9]{2})|(2[0-9]{3})-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01]) ([01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9]" )
    private String deliverTime;

    public String getSource() {
        return source;
    }

    public void setSource(String source) {
        this.source = source;
    }

    public Integer getKindId() {
        return kindId;
    }

    public void setKindId(Integer kindId) {
        this.kindId = kindId;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getDeliverTime() {
        return deliverTime;
    }

    public void setDeliverTime(String deliverTime) {
        this.deliverTime = deliverTime;
    }

    @Override
    public String toString() {
        return "EventBasicData{" +
            "source='" + source + '\'' +
            ", kindId=" + kindId +
            ", name='" + name + '\'' +
            ", deliverTime='" + deliverTime + '\'' +
            '}';
    }
}
